package org.atlantis.grosbeak.cable;

import org.atlantis.grosbeak.lang.Exceptions;

/**
 * 对用户的ActionMethod进行执行操作。用户不需要考虑此类。
 * 
 * @author <a href="mailto:seenoevil.cn@gmail.com">SeeNoEvil</a>
 * 
 */
public class Orderly {

	private ActionDesc actionDesc;
	private Object[] args;
	
	public Orderly(ActionDesc actionDesc, Object[] args) {
		this.actionDesc = actionDesc;
		this.args = args;
	}
	
	/**
	 * 执行。
	 * @return ActionMethod的执行结果。
	 * @throws CableException
	 */
	public Object execution() throws CableException {
		try {
			return actionDesc.method.invoke(actionDesc.instance, args);
		} catch (Exception e) {
			throw Exceptions.wrapThrow(CableException.class, e);
		}
	}
}
